package com.seleniti.enpareja.controller.ui.view;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.ioc.commons.flowcontrol.actioncontroller.IsExternalAction;
import org.ioc.commons.flowcontrol.eventbus.IsEvent;
import org.ioc.commons.flowcontrol.operationmanager.IsOperation;
import org.ioc.commons.ui.HasEnabled;
import org.ioc.commons.ui.HasLoader;
import org.ioc.commons.ui.HasValue;
import org.ioc.commons.ui.HasVisibility;
import org.ioc.commons.ui.IsView;
import org.ioc.commons.ui.IsViewPresenter;
import org.ioc.commons.ui.features.HasBoards;
import org.ioc.commons.ui.features.IsBoard;

import com.seleniti.enpareja.controller.model.integration.database.domain.SharedExpense;
import com.seleniti.enpareja.controller.model.integration.database.domain.SharedExpense.MadeBy;
import com.seleniti.enpareja.controller.ui.view.SharedExpensesView.Board;

public interface SharedExpensesView extends
		EnParejaView<SharedExpensesView.Event, SharedExpensesView.Operation, SharedExpensesView.Action>, HasLoader,
		HasEnabled, HasBoards<Board> {

	@interface Fires {
		SharedExpensesView.Event[] value();
	}

	@interface Invokes {
		SharedExpensesView.Action[] value();
	}

	@interface Performs {
		SharedExpensesView.Operation[] value();
	}

	public enum Event implements IsEvent {
	}

	public enum Operation implements IsOperation {
		GettingData, Saving, Deleting
	}

	public enum Action implements IsExternalAction {
	}

	public interface Presenter extends IsViewPresenter {

		void onActionModeChanged();

		void onSelectionChanged();

		void onElementModified();

		void onAddSharedExpense(MadeBy madeBy);

		void onCleanBill();

		boolean onGoBoardBack();
	}

	public enum ActionMode {
		DELETE_ELEMENT, MODIFY_ELEMENT;
	}

	public enum DebtsStatus {
		CLEAN, MEMBER1_OWES, MEMBER2_OWES, SINGLE;
	}

	public enum Board implements IsBoard {
		MAIN_LIST, EDIT_FORM
	}

	void setActionMode(ActionMode mode);

	List<SharedExpense> elementList();

	ActionMode getActionMode();

	Set<SharedExpense> getSelection();

	void showModifyForm(SharedExpense toModify);

	SharedExpense modifyingElement();

	void saveModificationForm();

	void hideModificationForm();

	HasValue<Date> formDate();

	HasValue<String> formText();

	HasValue<BigDecimal> formAmount();

	HasValue<String> member1Name();

	HasValue<String> member2Name();

	boolean checkformValidity();

	void addSharedExpense(MadeBy madeBy);

	HasValue<BigDecimal> totalMember1();

	HasValue<BigDecimal> totalMember2();

	void setDebtsStatus(DebtsStatus status, BigDecimal amount);

	void clearSelection();

	void scrollToElement(int idx);

	HasValue<Boolean> formShared();

	HasValue<Boolean> total1IncludeNotShared();
	
	HasValue<Boolean> total2IncludeNotShared();

	HasVisibility member1ActionsVisible();
	
	HasVisibility member2ActionsVisible();

	HasEnabled notSharedActionEnabled();
}
